<?php
namespace api\components;


use Yii;
use yii\base\Exception;
/**
 * 用户修改规则 根据用户传入的id 判断是否与当前的登录的账户ID一致，一致则代表能够修改该资料
 */
class Email
{
    /**
     * [sendText 发送邮件]
     * @Author   panwc
     * @DateTime 2017-12-27T17:51:25+0800
     * @param    [array]                   $recipients [邮件内容]
     * @param    [string]                   $subject    [邮件主题]
     * @param    [string]                   $body       [description]
     * @return   [type]                               [description]
     */
    public static function sendEmail($recipients,$subject,$body)
    {

        try{
            $messages = [];
            foreach ($recipients as $recipient) {
                $messages[] = Yii::$app->mailer->compose('approve_'.\Yii::$app->language,$body)
                        ->setTo($recipient)
                        ->setSubject($subject);

            }
            Yii::$app->mailer->sendMultiple($messages);

        }catch(\Exception $e){
            var_dump($e);exit;

        }
    }
}
